<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<%@ include file="/WEB-INF/views/include/header.jsp"%>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-cmsNews-edit" object="${cmsNewsDTO}">
            <input id="contentId" name="contentId" value="${cmsNewsDTO.contentId}"  type="hidden">
            <input id="treeId" name="catId" type="hidden" value="${cmsNewsDTO.catId}"   />
            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label required_hold"><em class="required_red">*</em>栏目</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <input class="form-control" type="text" name="catName" value="${cmsNewsDTO.catName}" onclick="selectCateTree()" readonly="true" id="treeName">
                                <span class="input-group-btn">
								<button type="button" onclick="selectCateTree()" class="btn btn-default">选择</button>
							</span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label required_hold"><em class="required_red">*</em>标题 </label>
                        <div class="col-sm-10">
                            <input id="title" name="title" value="${cmsNewsDTO.title}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label required_hold">完整标题 </label>
                        <div class="col-sm-10">
                            <input id="fullTitle" name="fullTitle" value="${cmsNewsDTO.fullTitle}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label required_hold">关键词 </label>
                        <div class="col-sm-10">
                            <input id="keywords" name="keywords" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label required_hold"><em class="required_red">*</em>描述 </label>
                        <div class="col-sm-10">
                            <textarea id="description" name="description"  rows="5" maxlength="450" class="form-control">${cmsNewsDTO.description}</textarea>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label required_hold"><em class="required_red">*</em>优先级 </label>
                        <div class="col-sm-8">
                            <input id="priority" name="priority" value="${cmsNewsDTO.priority}" class="form-control" type="text">
                        </div>
                    </div>
                </div>

                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label required_hold"><em class="required_red">*</em>发布时间 </label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input type="text" id="publishDate" name="publishDate" value="${cmsNewsDTO.publishDate}"  class="form-control time-input " style="padding-left:3px;padding-right:3px;"/>
                                <span class="input-group-addon" style="padding-left:3px;padding-right:3px;">至</span>
                                <input type="text" id="offDate" name="offDate" value="${cmsNewsDTO.offDate}"  class="form-control time-input" style="padding-left:3px;padding-right:3px;"/>
                            </div>

                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label required_hold"><em class="required_red">*</em>作者 </label>
                        <div class="col-sm-8">
                            <input id="author" name="author" value="${cmsNewsDTO.author}" class="form-control" type="text">
                        </div>
                    </div>
                </div>

                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label required_hold">来源 </label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input type="text" name="source" value="${cmsNewsDTO.source}" class="form-control " style="padding-left:3px;padding-right:3px;"/>
                                <span class="input-group-addon" style="padding-left:3px;padding-right:3px;">地址</span>
                                <input type="text" name="sourceUrl" value="${cmsNewsDTO.sourceUrl}" class="form-control" style="padding-left:3px;padding-right:3px;"/>
                            </div>

                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <label class="col-sm-2 control-label required_hold"><em class="required_red">*</em>详情 </label>
                        <div class="col-sm-10">
                            <textarea id="editor" name="content" style="width: 99%;height: 360px;">${cmsNewsDTO.content}</textarea>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-12">
                    <div class="form-group">
                        <div class="col-sm-12" style="text-align: center">
                            <button class="btn btn-success" onclick="submitHandler();" type="button" style="width: 90px;">保存</button>
                            <button class="btn btn-default" onclick="submitHandler();" type="button" style="width: 90px;">保存并审核</button>
                            <button class="btn btn-default" onclick="submitHandler();" type="button" style="width: 90px;">保存并关闭</button>
                        </div>
                    </div>
                </div>
            </div>

		</form>
    </div>
    <%@ include file="/WEB-INF/views/include/footer.jsp"%>
    <script type="text/javascript">
		var prefix = ctx + "cms/cmsNews"
		$("#form-cmsNews-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-cmsNews-edit').serialize());
	        }
	    }
        var ue = UE.getEditor('editor');

        /*用户管理-新增-选择栏目树*/
        function selectCateTree() {
            var treeId = $("#treeId").val();
            var catId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "cms/category/selectCateTree/" + catId;
            var options = {
                title: '选择栏目',
                width: "380",
                url: ctx + "cms/category/selectCateTree/" + catId,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }




	</script>
</body>
</html>
